#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ._base import CrmConfig, AdminConfig, ApiConfig

all = ['ProdAdminConfig', 'ProdCrmConfig', 'ProdApiConfig']


class ProdMixin(object):
    RUN_ENV = 'prod'
    DEBUG = False

    WEB_HOST = 'http://admin.tlwhkj.com/'
    SESSION_COOKIE_DOMAIN = 'admin.tlwhkj.com'
    # SITE_STATIC_PREFIX = 'http://static.sglalaw.com/static/'

    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://big_data:Linlong219@rm-bp193z0m7lmk92b81.mysql.rds.aliyuncs.com:3306/fan_xian?charset=utf8mb4"
    SQLALCHEMY_BINDS = {
        'fx': "mysql+pymysql://big_data:Linlong219@rm-bp193z0m7lmk92b81.mysql.rds.aliyuncs.com:3306/fan_xian?charset=utf8mb4",
    }

    MOBILE_ENABLE = True
    # 连接池
    SQLALCHEMY_POOL_SIZE = 10
    SQLALCHEMY_POOL_TIMEOUT = 5
    # 连接池重连时间 6 小时
    SQLALCHEMY_POOL_RECYCLE = 6 * 3600


    # redis
    REDIS_DB = 1
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # REDIS_PASSWORD = 'om_redis$%^'

    IMAGES_DOMAIN = 'http://images.sglalaw.com/'
    UPLOAD_FOLDER = "/data/images/fx/"

    # celery 配置
    CELERY_BROKER_URL = 'redis://localhost:6379'


class ProdAdminConfig(ProdMixin, AdminConfig):
    def __init__(self):
        self.LOGGERS['fx']['level'] = 'INFO'
        self.LOGGERS['fx'][
            'file'] = '/data/log/fx/prod/admin/admin.log'


class ProdCrmConfig(ProdMixin, CrmConfig):
    def __init__(self):
        self.LOGGERS['fx']['level'] = 'INFO'
        self.LOGGERS['fx'][
            'file'] = '/data/log/fx/prod/web/crm.log'


class ProdApiConfig(ProdMixin, ApiConfig):
    def __init__(self):
        self.LOGGERS['om']['level'] = 'INFO'
        self.LOGGERS['om'][
            'file'] = '/data/log/fx/prod/web/api.log'
